﻿using NewRetail.Application.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

#nullable enable

namespace NewRetail.Application.Components.WeChat.CardVoucher.Model
{
    public class MarketingFavorStockCreateInputDto
    {
        /// <summary>
        /// 商户号
        /// </summary>
        [Required]
        public string MerchantId { get; set; } = string.Empty;
        /// <summary>
        /// 批次名称
        /// </summary>
        [Required]
        public string StockName { get; set; } = string.Empty;
        /// <summary>
        /// 归属商户号.本字段暂未开放生效，但入参时请设置为当前创建代金券商户号即不会报错，暂时不支持入参其他的商户号
        /// </summary>
        public string BelongMerchantId { get; set; } = string.Empty;
        /// <summary>
        /// 批次备注
        /// </summary>
        public string Comment { get; set; } = string.Empty;
        /// <summary>
        /// 可用开始时间
        /// </summary>
        [Required]
        public DateTimeOffset AvailableBeginTime { get; set; }
        /// <summary>
        /// 可用结束时间
        /// </summary>
        [Required]
        public DateTimeOffset AvailableEndTime { get; set; }
        /// <summary>
        /// 最大发券数。1、发放总个数最少5个 2、发放总个数最多1000万个
        /// </summary>
        [Required]
        public int MaxCoupons { get; set; }
        /// <summary>
        /// 最大发券预算
        /// </summary>
        [Required]
        public long MaxAmount { get; set; }
        /// <summary>
        /// 获取或设置单天预算发放上限（单位：分）。
        /// </summary>
        public long MaxAmountPerDay { get; set; }
        /// <summary>
        /// 获取或设置单个用户可领个数
        /// </summary>
        [Required]
        public int MaxCouponsPerUser { get; set; }
        /// <summary>
        /// 获取或设置是否开启自然人限制,当开启了自然人限领时，多个微信号同属于一个身份证时，视为同一用户
        /// </summary>
        [Required]
        public bool IsNaturalPersonLimit { get; set; }
        /// <summary>
        /// 获取或设置是否开启防刷拦截。若开启防刷拦截，当用户命中恶意、小号、机器、羊毛党、黑产等风险行为时，无法成功发放代金券
        /// </summary>
        [Required]
        public bool IsPreventApiAbuse { get; set; }
        /// <summary>
        /// 获取或设置可用星期数。
        /// </summary>
        public int? AvailableWeekDay { get; set; }

        /// <summary>
        /// 获取或设置当天开始时间（单位：秒）。
        /// </summary>
        public int? BeginTimeSeconds { get; set; }

        /// <summary>
        /// 获取或设置当天结束时间（单位：秒）。
        /// </summary>
        public int? EndTimeSeconds { get; set; }
        /// <summary>
        /// 获取或设置是否领取后 N 天有效。
        /// </summary>
        public bool? IsSecondDayAvailable { get; set; }

        /// <summary>
        /// 获取或设置领取后有效时间（单位：分钟）。
        /// </summary>
        public int? AvailableMinutesAfterReceive { get; set; }
        /// <summary>
        /// 获取或设置券面额（单位：分）。
        /// </summary>
        [Required]
        public int CouponAmount { get; set; }

        /// <summary>
        /// 获取或设置使用门槛（单位：分）。
        /// </summary>
        [Required]
        public int TransactionMinimum { get; set; }
        /// <summary>
        /// 获取或设置订单优惠标记列表。
        /// </summary>
        public IList<string>? GoodsTagList { get; set; }

        /// <summary>
        /// 获取或设置指定付款方式编码列表。
        /// </summary>
        public IList<string>? LimitPayCodeList { get; set; }
        /// <summary>
        /// 获取或设置银行卡名称。
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 获取或设置指定卡 BIN 列表。
        /// </summary>
        public IList<string>? BinList { get; set; }
        /// <summary>
        /// 获取或设置指定支付方式列表。
        /// </summary>
        public IList<string>? TradeTypeList { get; set; }

        /// <summary>
        /// 获取或设置是否可叠加其他优惠。
        /// </summary>
        public bool? AllowCombineUse { get; set; }

        /// <summary>
        /// 获取或设置可核销商品编码列表。
        /// </summary>
        public IList<string>? AvailableItems { get; set; }
        /// <summary>
        /// 获取或设置不可核销商品编码列表。
        /// </summary>
        public IList<string>? UnavailableItems { get; set; }

        /// <summary>
        /// 获取或设置可用商户号列表。
        /// </summary>
        public IList<string>? AvailableMerchantIdList { get; set; }
        /// <summary>
        /// 获取或设置是否无资金流。
        /// </summary>
        [Required]
        public bool IsNoCash { get; set; }
        /// <summary>
        /// 获取或设置批次类型。仅支持：NORMAL：固定面额满减券批次
        /// </summary>
        [Required]
        public string StockType { get; set; } = string.Empty;

        /// <summary>
        /// 获取或设置商户单据号。
        /// </summary>
        [Required]
        public string OutRequestNumber { get; set; } = string.Empty;
        /// <summary>
        /// 获取或设置扩展属性。
        /// </summary>
        public string? Extdata { get; set; }
        /// <summary>
        /// 获取或设置使用说明。
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 获取或设置品牌 Logo 媒体文件地址。
        /// </summary>
        public string? MerchantLogoMediaUrl { get; set; }

        /// <summary>
        /// 获取或设置品牌名称。
        /// </summary>
        public string? MerchantName { get; set; }

        /// <summary>
        /// 获取或设置背景颜色。
        /// </summary>
        public string? BackgroundColor { get; set; }

        /// <summary>
        /// 获取或设置券详情图片媒体文件地址。
        /// </summary>
        public string? CouponImageMediaUrl { get; set; }
    }

    public class MarketingFavorStockActiveInputDto
    {
        /// <summary>
        /// 商户号
        /// </summary>
        [Required]
        public string MerchantId { get; set; } = string.Empty;
        /// <summary>
        /// 批次创建方的商户号,如果不填则默认使用商户号
        /// </summary>
        public string? StockCreatorMchid { get; set; }
        /// <summary>
        /// 批次号
        /// </summary>
        [Required]
        public string StockId { get; set; } = string.Empty;
    }

    public class MarketingFavorStockSendInputDto
    {
        /// <summary>
        /// 商户号
        /// </summary>
        [Required]
        public string MerchantId { get; set; } = string.Empty;
        /// <summary>
        /// 获取或设置批次号。
        /// </summary>
        public string StockId { get; set; } = string.Empty;

        /// <summary>
        /// 获取或设置创建批次的商户号。
        /// </summary>
        public string? StockCreatorMerchantId { get; set; }

        /// <summary>
        /// 获取或设置微信 AppId。
        /// </summary>
        public string AppId { get; set; } = string.Empty;

        /// <summary>
        /// 获取或设置用户唯一标识。
        /// </summary>
        public string OpenId { get; set; } = string.Empty;

        /// <summary>
        /// 获取或设置商户单据号。
        /// </summary>
        public string OutRequestNumber { get; set; } = string.Empty;

        /// <summary>
        /// 获取或设置指定发券面额（单位：分）。
        /// </summary>
        public int? CouponAmount { get; set; }

        /// <summary>
        /// 获取或设置指定发券使用门槛（单位：分）。
        /// </summary>
        public int? TransactionMinimum { get; set; }
    }

    public class MarketingFavorStockQueryInputDto
    {
        /// <summary>
        /// 创建批次的商户号
        /// </summary>
        [Required]
        public string StockCreatorMchid { get; set; } = string.Empty;
        /// <summary>
        /// 分页页码
        /// </summary>
        [Required]
        public int Offset { get; set; }
        /// <summary>
        /// 分页大小
        /// </summary>
        [Required]
        public int Limit { get; set; }
    }

    //由于前端展示问题，弃用，使用如下的MarketingFavorStockUserCouponsDto
    public class LocalMarketingFavorStockUserCouponsDto
    {
        /// <summary>
        /// 批次Id
        /// </summary>
        public string StockId { get; set; } = string.Empty;
        /// <summary>
        /// 单据号
        /// </summary>
        public string OutRequestNo { get; set; } = string.Empty;
        /// <summary>
        /// 批次名称
        /// </summary>
        public string StockName { get; set; } = string.Empty;
        /// <summary>
        /// 可用结束时间
        /// </summary>
        public string AvailableEndTime { get; set; } = string.Empty;
        /// <summary>
        /// 可用开始时间
        /// </summary>
        public string AvailableBeginTime { get; set; } = string.Empty;
        /// <summary>
        /// 活动期间每个用户可领个数，当开启了自然人限领时，多个微信号同属于一个身份证时，视为同一用户。
        /// </summary>
        public int MaxCouponsPerUser { get; set; }
        /// <summary>
        /// 最大发券数。1、发放总个数最少5个   2、发放总个数最多1000万个
        /// </summary>
        public long MaxCoupons { get; set; }
        /// <summary>
        /// 已发券数量
        /// </summary>
        public int DistributedCoupons { get; set; }
        /// <summary>
        /// 券面额，单位：分
        /// </summary>
        public long CouponAmount { get; set; }
        public List<Types.Coupon>? CouponList { get; set; }
        public static class Types
        {
            public class Coupon
            {
                /// <summary>
                /// 领券id
                /// </summary>
                public string CouponId { get; set; } = string.Empty;
                /// <summary>
                /// 券状态 NULL或SENDED：可用   USED：已实扣  EXPIRED：已过期
                /// </summary>
                public string? CouponStatus { get; set; }
                /// <summary>
                /// 微信openid
                /// </summary>
                public string OpenId { get; set; } = string.Empty;
                /// <summary>
                /// 会员名
                /// </summary>
                public string MemberName { get; set; } = string.Empty;
                /// <summary>
                /// 会员手机
                /// </summary>
                public string MemberTel { get; set; } = string.Empty;
                /// <summary>
                /// 会员号
                /// </summary>
                public string MemberNo { get; set; } = string.Empty;
            }
        }

    }

    public class MarketingFavorStockUserCouponsDto
    {
        /// <summary>
        /// 批次Id
        /// </summary>
        public string StockId { get; set; } = string.Empty;
        /// <summary>
        /// 单据号
        /// </summary>
        public string StockOutRequestNo { get; set; } = string.Empty;
        /// <summary>
        /// 批次名称
        /// </summary>
        public string StockName { get; set; } = string.Empty;
        /// <summary>
        /// 可用结束时间
        /// </summary>
        public string AvailableEndTime { get; set; } = string.Empty;
        /// <summary>
        /// 可用开始时间
        /// </summary>
        public string AvailableBeginTime { get; set; } = string.Empty;
        /// <summary>
        /// 活动期间每个用户可领个数，当开启了自然人限领时，多个微信号同属于一个身份证时，视为同一用户。
        /// </summary>
        public int MaxCouponsPerUser { get; set; }
        /// <summary>
        /// 最大发券数。1、发放总个数最少5个   2、发放总个数最多1000万个
        /// </summary>
        public long MaxCoupons { get; set; }
        /// <summary>
        /// 已发券数量
        /// </summary>
        public int DistributedCoupons { get; set; }
        /// <summary>
        /// 券面额，单位：分
        /// </summary>
        public long CouponAmount { get; set; }
        /// <summary>
        /// 领券id
        /// </summary>
        public string CouponId { get; set; } = string.Empty;
        /// <summary>
        /// 券状态 NULL或SENDED：可用   USED：已实扣  EXPIRED：已过期
        /// </summary>
        public string? CouponStatus { get; set; }
        /// <summary>
        /// 发券单据号
        /// </summary>
        public string? CouponOutRequestNo { get; set; }
        /// <summary>
        /// 发券时间
        /// </summary>
        public DateTime? CouponSendDateTime { get; set; }
        /// <summary>
        /// <summary>
        /// 微信openid
        /// </summary>
        public string? OpenId { get; set; }
        /// <summary>
        /// 会员名
        /// </summary>
        public string? MemberName { get; set; }
        /// <summary>
        /// 会员手机
        /// </summary>
        public string? MemberTel { get; set; }
        /// <summary>
        /// 会员号
        /// </summary>
        public string? MemberNo { get; set; }

    }
    public class MarketingFavorStockUserCouponsInputDto : PagingRequestDto
    {
        /// <summary>
        /// 券Id
        /// </summary>
        public string? StockId { get; set; }
        /// <summary>
        /// 券状态（枚举值：0  可用   1 已用或已过期）
        /// </summary>
        public string? CouponStatus { get; set; }
        /// <summary>
        /// OpenId
        /// </summary>
        public string? OpenId { get; set; }
        /// <summary>
        /// 手机号或No号
        /// </summary>
        public string? TelOrNo { get; set; }
        /// <summary>
        /// 发券开始日期
        /// </summary>
        public string? BeginDate { get; set; }
        /// <summary>
        /// 发券结束日期
        /// </summary>
        public string? EndDate { get; set; }
    }

    public class CardVoucherIntegralPagingDto : PagingRequestDto
    {
        public string? stockId { get; set; }
    }

    public class MarketingFavorStockIntegralDto
    {

    }
}
